const categoryModel = require("../models/categoryModel");

module.exports = {
  //   获取所有分类
  async getAllCategory() {
    return await categoryModel.find();
  },
  //     增加分类
  async createCategory(category) {
    return await categoryModel.create(category);
  },
  //     删除分类
  async deleteCategory(id) {
    return await categoryModel.deleteOne({ _id: id });
  },
  //     修改分类
  async updateCategory(id, category) {
    return await categoryModel.updateOne({ _id: id }, category);
  },
};
